<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <input type="hidden" id="code" value="${code}"/>
        <t:datagrid name="cbsContractList" checkbox="true" fitColumns="false"
                    title="服务合同信息" actionUrl="cbsContractController.do?datagridMc" idField="id" fit="true"
                    queryMode="group">
            <t:dgCol title="主键" field="id" hidden="true" queryMode="single" width="120"></t:dgCol>
            <t:dgCol title="id" field="cid" hidden="true" queryMode="single" width="120"></t:dgCol>
            <t:dgCol title="设备序列号" field="sn" queryMode="single" width="100" query="true"></t:dgCol>
            <t:dgCol title="机型" field="equipmentType" queryMode="single" width="110"></t:dgCol>
            <t:dgCol title="甲方名称" field="clientName" queryMode="single" width="250" query="true"></t:dgCol>
            <t:dgCol title="所属影院名称" field="cinemaName" queryMode="single" width="250" query="true"></t:dgCol>
            <t:dgCol title="合同编号" field="contractCode" queryMode="single" width="180" query="true"
                     url="cbsContractController.do?goCheck&id={cid}" funname="goCheck"></t:dgCol>
            <t:dgCol title="合同类型" field="contractType" queryMode="single"
                     dictionary="<%=StaticValue.CBS_CONTRACT_TYPE %>" width="90" query="true"></t:dgCol>
            <t:dgCol title="维保开始时间" field="serviceStartDate" formatter="yyyy-MM-dd" queryMode="group"
                     width="110"></t:dgCol>
            <t:dgCol title="维保截止时间" field="serviceEndDate" formatter="yyyy-MM-dd" queryMode="group" width="110"
                     query="true"></t:dgCol>
            <t:dgCol title="有效状态" field="status" dictionary="<%=StaticValue.mc_status %>" queryMode="single" width="80"
                     query="true"></t:dgCol>
            <t:dgCol title="付款状态" field="payStatus" dictionary="<%=StaticValue.CBS_CONTRACT_PAYSTATUS %>"
                     queryMode="single" width="80" query="true"></t:dgCol>
            <t:dgCol title="合同状态" field="contractStatus" hidden="true" dictionary="<%=StaticValue.CBS_CONTRACT_STATE %>"
                     queryMode="single" width="120" query="true"></t:dgCol>
            <t:dgCol title="合同生效时间" field="contractDate" formatter="yyyy-MM-dd" queryMode="group" width="110"
                     query="true"></t:dgCol>
            <t:dgCol title="系统MC" field="mcCode" queryMode="single" width="100"></t:dgCol>
            <t:dgToolBar title="新建合同" icon="icon-add" funname="add" operationCode="addContract"></t:dgToolBar>
            <t:dgToolBar title="修改合同" icon="icon-edit" funname="updatecontract" operationCode="updateContract"></t:dgToolBar>
            <t:dgToolBar title="导入MC" icon="icon-put" funname="ImportXls" operationCode="importContract"></t:dgToolBar>
            <t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls" operationCode="exportContract"></t:dgToolBar>
        </t:datagrid>
    </div>
</div>
<script src="webpage/com/zybk/cbscontract/cbsContractList.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //给时间控件加上样式
        $("#cbsContractListtb").find("input[name='serviceEndDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsContractListtb").find("input[name='serviceEndDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsContractListtb").find("input[name='contractDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsContractListtb").find("input[name='contractDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        var code = $("#code").val();
        if (code == "add") {
            tip("服务合同信息添加成功");
        } else if (code == "update") {
            tip("服务合同信息更新成功");
        } else if (code == "recoke") {
            tip("服务合同已撤销");
        }
    });

    //导入
    function ImportXls() {
        var datas = $("#cbsContractList").datagrid("getSelections");
        if (datas.length == 0) {
            openwindow('Excel导入', 'cbsContractController.do?upload', "cbsContractList");
        }
        if (datas[0].contractType == 3) {
            tip("模板合同的不能导入MC");
        } else {
            openwindow('Excel导入', 'cbsContractController.do?upload', "cbsContractList");
        }
    }

    //导出
    function ExportXls() {
        var currPageRows = $("#cbsContractList").datagrid("getRows");
        var idsData = [];
        $(currPageRows).each(function (i, rowData) {
            idsData.push(rowData.cid);
        });
        if (idsData.length > 0) {
            myDownload("cbsContractController.do?exportXls", "planIds=" + idsData.join(","));
        } else {
            tip("请选择要导出的数据");
        }
    }

    //模板下载
    function ExportXlsByT() {
        JeecgExcelExport("cbsContractController.do?exportXlsByT", "cbsContractList");
    }

    function add() {
        addOneTab('新建合同', 'cbsContractController.do?goAdd', '');
    }

    function updatecontract() {
        var datas = $("#cbsContractList").datagrid("getSelections");
        if (datas.length > 1) {
            tip("请选择一条合同");
            return;
        }
        var id = datas[0].cid;
        addOneTab('修改合同', 'cbsContractController.do?goUpdate&id=' + id, '');
    }

    function goCheck(filedName, url) {
        addOneTab("合同详情", url);
    }
</script>